<script setup lang='ts'>
    import {onMounted, ref} from 'vue'
    import * as echarts from 'echarts'
    const charts = ref<any>()
        onMounted(() => {
        // 获取echarts实例
        const mycharts = echarts.init(charts.value)
        const option = {
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    top: 40,
                    orient: 'vertical', // 小图例方向
                    right: 30,
                    textStyle: {
                        color: 'white',
                        fontSize: 14,
                    },
                },
                series: [
                    {
                    name: 'Access From',
                    type: 'pie',
                    radius: ['40%', '70%'],
                    avoidLabelOverlap: false,
                    itemStyle: {
                        borderRadius: 10,
                        borderColor: '#fff',
                        borderWidth: 2
                    },
                    label: {
                        show: true,
                        position: 'inside',
                        color: 'white'
                    },
                    emphasis: {
                        label: {
                        show: true,
                        fontSize: 40,
                        fontWeight: 'bold'
                        }
                    },
                    labelLine: {
                        show: false
                    },
                    data: [
                        { value: 1048, name: '军事' },
                        { value: 735, name: '财经' },
                        { value: 580, name: '娱乐' },
                        { value: 484, name: '直播' },
                        { value: 300, name: '新闻' }
                    ]
                    }
                ],
                 // 布局组件
                grid: {
                    left: 0,
                    right: 0,
                    bottom: 0,
                    top: 0
                }
            };
        mycharts.setOption(option )
    })
</script>


<template>
    <div class="box3">
        <div class="title">
            <Title title="年龄比例"></Title>
        </div>
        <div ref="charts" class="charts"></div>
    </div>
</template>


<style scoped lang='scss'>
    .box3{
        width: 100%;
        height: 100%;
        background: url('@/views/screen/images/dataScreen-main-cb.png') no-repeat;
        background-size: 100% 100%;
        .title{
            margin-left: 20px;
        }
        .charts{
            height: 260px;
        }
    }
</style>